fix: correct unphysical ell_comps in tutorial 3 model-fitting exercise - #65
Merged
Merged
Conversation
The manual model-fitting exercise at the end of tutorial 3 shipped `ell_comps=(0.5, 0.9)` as its deliberately-poor starting guess. That pair has magnitude f = 1.0296, and the axis ratio is q = (1 - f) / (1 + f), so it implies q = -0.015 — an ellipse with negative axis ratio, which has no geometric meaning. The value was always unphysical; it only became visible when PyAutoGalaxy added the `EllProfile` guard that rejects f >= 1. Use `(0.5, 0.5)` instead: f = 0.707, q = 0.17. Still a wildly wrong starting point against the simulator's true bulge (axis_ratio=0.9, angle=45deg, i.e. ell_comps ~ (0.053, 0.0)), so the exercise keeps its "adjust these to improve the fit" pedagogy, but the profile is now geometrically valid. Applied to the script and to both generated mirrors (notebook, markdown) so the scripts and notebooks smoke legs agree. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K4jSvqKzCMvqcF4b3wWXFq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The manual model-fitting exercise at the end of
tutorial_3_fittingshippedell_comps=(0.5, 0.9)as its deliberately-poor starting guess. That pair has magnitudef = 1.0296, and the axis ratio isq = (1 - f) / (1 + f), so it impliesq = -0.015— an ellipse with a negative axis ratio, which has no geometric meaning.The value was always unphysical. It only became visible when PyAutoGalaxy added the
validate_ell_compsguard onEllProfile(the single base every elliptical profile inherits), which rejectsf >= 1.Changed to
(0.5, 0.5):f = 0.707,q = 0.17. Still a wildly wrong starting point against the simulator's true bulge (axis_ratio=0.9, angle=45deg, i.e.ell_comps ~ (0.053, 0.0)), so the exercise keeps its "adjust these to improve the fit" pedagogy — the neighbouringcentre=(1.0, 10)is left deliberately bad too. The profile is now geometrically valid.Why fix the value rather than the guard
The guard is correct and correctly placed:
q = (1 - f) / (1 + f)is a valid axis ratio in(0, 1]only whilef < 1; atf == 1the ellipse degenerates toq == 0and beyond itqgoes negative. Relaxing it would re-admit profiles that return a finite but meaningless image.Scope
Applied to the script and to both generated mirrors, so the
run_scriptsandrun_notebookslegs agree:scripts/chapter_1_introduction/tutorial_3_fitting.pynotebooks/chapter_1_introduction/tutorial_3_fitting.ipynbmarkdown/chapter_1_introduction/tutorial_3_fitting.mdEvidence
Surfaced by PyAutoHeart Workspace Smoke run 31356506626 (2026-08-10). The
howtogalaxy / chapter_1_introductionleg had exactly one failure — this script — with the other six passing:An AST scan of 454
ell_compsliterals acrossautogalaxy_workspace,autolens_workspace,HowToGalaxy,HowToLensand both*_workspace_testrepos found no other violating literal and no out-of-rangeaxis_ratioconversion, so this is the complete literal surface.Not in scope
The other red legs in that run are two different causes, neither fixed here:
guideslegs fail on Nautilus prior draws (e.g.np.float64(-0.7446446619131553)), not literals — already fixed by PyAutoGalaxy#568, which makesModelParameterExceptionaFitExceptionso searches resample. That run started 18 hours before #568 merged.*_workspace_testaggregator legs fail on(1.0, 1.0)from PyAutoFit's mock scaffolding — filed as a PyAutoMind bug prompt.🤖 Generated with Claude Code
Generated by Claude Code